package com.pay.game.central.web.mapper;


import com.pay.game.central.web.bean.Rent;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface RentMapper {

    @Insert("<script>" +
            "   INSERT INTO rent(settlement_id, father_rate, rate, `date`, `time`, value, run_score, " +
            "     store_id, store_name, user_name, user_id, p_user_id, p_user_name) VALUES" +
            "       <foreach collection=\"list\" item=\"rent\" separator=\",\"> "+
            "           ( #{rent.settlement_id, jdbcType=BIGINT}," +
            "             #{rent.father_rate, jdbcType=FLOAT}," +
            "             #{rent.rate, jdbcType=FLOAT}," +
            "             #{rent.date, jdbcType=DATE}," +
            "             #{rent.time, jdbcType=INTEGER}," +
            "             #{rent.value, jdbcType=INTEGER}," +
            "             #{rent.run_score, jdbcType=INTEGER}," +
            "             #{rent.store_id}, "+
            "             #{rent.store_name}, "+
            "             #{rent.user_name}, "+
            "             #{rent.user_id},"+
            "             #{rent.p_user_id}, "+
            "             #{rent.p_user_name}) "+
            "       </foreach>"+
            "</script>"
    )
    void addRents(List<Rent> list);


    @Select("select value,`date` from rent where p_user_id=#{userId} and `date` <= #{endDate} and `date` >= #{startDate}")
    List<Rent> queryPeriod(@Param("userId") String userId, @Param("startDate") String startDate, @Param("endDate") String endDate);

}
